<?php
/**
 * 身份证号
 * @author yupoxiong<i@yufuping.com>
 */

namespace generate\field;

class IdCard extends Field
{
    public static $html = <<<EOF
<div class="layui-form-item">
    <label for="[FIELD_NAME]"  class="layui-form-label [REQUIRED]">[FORM_NAME]</label>
    <div class="layui-input-inline">
        <input id="[FIELD_NAME]" name="[FIELD_NAME]" lay-verify="[FORM_VALIDATE]" value="{\$data.[FIELD_NAME]|default='[FIELD_DEFAULT]'}" placeholder="请输入[FORM_NAME]" type="text" lay-verify="identity"  class="layui-input">
    </div>
</div>\n
EOF;

    public static $rules = [
        'required' => '非空',
        'id_card'  => '身份证',
        'regular'  => '自定义正则'
    ];


    public static function create($data)
    {
        return str_replace(array('[FORM_NAME]', '[FIELD_NAME]', '[FIELD_DEFAULT]', '[FORM_VALIDATE]', '[REQUIRED]'), array($data['form_name'], $data['field_name'], $data['field_default'], self::$verify, self::$required), self::$html);
    }
}